package com.leyou.api;

import com.leyou.ResponseData;
import com.leyou.entity.Spu;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@RequestMapping("/goods")
public interface GoodsApi {

    /**
     * 分页查询商品
     * @param page 要查询第几页
     * @param rows 每页显示多少行数据
     * @param key 查询的内容
     * @param saleable 是否上架
     * @return
     */
    @GetMapping(path = "/spu/page")
    public ResponseData querySpuByPage(
            @RequestParam(value = "page",defaultValue = "1") Integer page,
            @RequestParam(value = "rows",defaultValue = "10") Integer rows,
            @RequestParam(value = "key",required = false) String key,
            @RequestParam(value="saleable",defaultValue = "true") Boolean saleable);

    /**
     * 根据spuid查询spu详情
     * @param id
     * @return
     */
    @GetMapping(path = "/spu/detail/{id}")
    ResponseData querySpuDetailById(@RequestParam(name = "id") Long id);

    /**
     * 根据spuid查询sku
     * @param id
     * @return
     */
    @GetMapping(path = "/sku/list")
    ResponseData querySkuBySpuId(@RequestParam(name = "id") Long id);

    /**
     * 根据spu的id查询spu
     * @param id
     * @return
     */
    @GetMapping("/spu/{id}")
//    ResponseData querySpuById(@PathVariable("id") Long id);
    Spu querySpuById(@PathVariable("id") Long id);
}
